<div class="layui-fluid" id="VIEW-list-table" lay-title="系统日志">
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm layui-btn-primary table-action" data-type="del">删除</div>
                        <div class="layui-btn layui-btn-sm layui-btn-primary sql-druid">监控</div>
                    </div>
                    <table id="list-table-log" lay-filter="list-table-log"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var jobId = "";
    layui.use(['admin', 'table', 'form', 'dropdown', 'jquery'], function (admin, table, form, dropdown, $) {
        var view = $('#VIEW-list-table');
        var tableFilter = 'list-table-log';
        table.render({
            elem: '[lay-filter="' + tableFilter + '"]',
            url: '/sysLog/page?token=' + admin.loginToken,
            height: 'full-165',
            cols: [[
                {title: '', type: 'checkbox', fixed: true, width: 60},
                {title: '用户ID', field: 'userId'},
                {title: '行为', field: 'operation'},
                {title: '请求方法', field: 'method', minWidth: 300},
                {title: '请求参数', field: 'params'},
                {title: 'IP', field: 'ip'},
                {title: '操作时间', field: 'createTime', align: 'center', minWidth: 250, templet: function (d) {
                    var createTime = layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss')
                    return '<p><span title="' + d.createTime + '" class="nepadmin-c-gray">' + createTime + '</span></p>';
                    }
                }
            ]]
        });
        view.find('.sql-druid').click(function () {
            var index = layer.open({
                type: 2,
                area: ['700px', '450px'],
                fixed: false, //不固定
                maxmin: true,
                content: '/druid/index.html'
            });
            layer.full(index);
        });
        view.find('.table-action').click(function () {
            var checkedCount = table.checkStatus(tableFilter).data.length;
            if (checkedCount == 0) {
                layer.msg('请先选择某行');
                return false;
            } else {
                // layer.msg($(this).html() + checkedCount + '项');
            }
            //直接删除
            var idArr = [];
            var data = table.checkStatus(tableFilter).data;
            data.forEach(function (val, index, arr) {//val为数组中当前的值，index为当前值的下表，arr为原数组
                idArr.push(val.id);
            });
            admin.post({
                url: '/sysLog/del/' + idArr.join(","),
                data: {
                    "token": admin.loginToken,
                    "_method": "DELETE"
                },
                dataType: 'json',
                success: function (data) {
                    layer.msg('删除成功');
                    table.reload('list-table-log', {
                        url: '/sysLog/page?token=' + admin.loginToken,
                        page: {
                            curr: 1
                        }
                    })
                }
            });
        })
    })
</script>